<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class CouponUsers extends Model
{


    const FULL_MIN=10; //满减
    const FULL_Z=20; //满折
    const NOW_MIN=30; //立减
    const NOW_Z=40; //立折

    public static $status=[
        self::FULL_MIN=>'满减',
        self::FULL_Z=>'满折',
        self::NOW_MIN=>'立减',
        self::NOW_Z=>'立折'
    ];

    public function coupon()
    {
        return $this->hasOne(Coupon::class,'id','coupon_id');
    }

    static public function isCheckCoupon($coupon_id,$users)
    {
        return self::where('coupon_id',$coupon_id)
            ->where('users_id',$users)
            ->with('coupon')
            ->find();
    }
}
